package com.fr.report.script.function;

import com.fr.base.FRContext;
import com.fr.report.script.Function;
import com.fr.report.script.Function.Type;
import com.fr.report.script.NormalFunction;
import com.fr.report.script.Primitive;
import java.util.logging.Level;
import java.util.logging.Logger;

public class TODOUBLE extends NormalFunction
{
  public Object run(Object[] paramArrayOfObject)
  {
    if (paramArrayOfObject.length < 1)
      return Primitive.ERROR_NAME;
    if (paramArrayOfObject.length > 0)
    {
      Object localObject = paramArrayOfObject[0];
      if (localObject instanceof Number)
        return new Double(((Number)localObject).doubleValue());
      try
      {
        return new Double(Double.parseDouble("" + localObject));
      }
      catch (NumberFormatException localNumberFormatException)
      {
        FRContext.getLogger().log(Level.WARNING, localNumberFormatException.getMessage(), localNumberFormatException);
      }
    }
    return new Double(0.0D);
  }

  public Function.Type getType()
  {
    return Function.TEXT;
  }

  public String getCN()
  {
    return "TODOUBLE(text): 将文本转换成Double对象。\nText:需要转换的文本。\n示例:\nTODOUBLE(\"123.21\")等于 new Double(123.21)。";
  }

  public String getEN()
  {
    return "TODOUBLE(text): Convert text to Double object.\n\nExample:\nTODOUBLE(\"123.21\") = new Double(123.21)。";
  }
}